'''
1.给两个字符串s和t,判断t是否为s的重新排列后组成的单词
    s = 'anagram' , t = 'nagaram' ,return true
    s = 'rat' ,t = 'car' ,return false
'''

def check(s,t):
    buckets1 = [0 for i in range(26)]
    buckets2 = [0 for i in range(26)]
    alphabet = ['a','b','c','d','e','f','g','h',
                'i','j','k','l','m','n','o','p','q',
                'r','s','t','u','v','w','x','y','z']
    for i in s:
        inds = alphabet.index(i)
        buckets1[inds] += 1
    print(buckets1)
    for j in t:
        indt = alphabet.index(j)
        buckets2[indt] += 1
    print(buckets2)
    return buckets1 == buckets2

s = 'anagram'
t = 'nagaram'
print(check(s,t))

s = 'rat'
t = 'car'
print(check(s,t))